#include <bits/stdc++.h>
#define int long long
#define PII pair <int, int>
using namespace std;
const int N = 5e3 + 5;
int n, pos, pos_, len, ans;
int sz[N];
multiset <int> st;
vector <int> p[N];
int dfs1(int u, int fa) {
	sz[u] = 1;
	for(int i : p[u]) if(i != fa) sz[u] += dfs1(i, u);
	st.insert(sz[u]);
	return sz[u];
}
void dfs2(int u, int fa, int dis) {
	st.erase(st.find(sz[u]));
	ans = max(ans, *st.rbegin() + dis);
	for(int i : p[u]) if(i != fa) dfs2(i, u, dis + 1);
	st.insert(sz[u]);
}
signed main() {
//	freopen("forest.in", "r", stdin);
//	freopen("forest.out", "w", stdout);
//	ios :: sync_with_stdio(0);
//	cin.tie(0), cout.tie(0);
	cin >> n >> n;
	for(int i = 2, x; i <= n; i ++ ) {
		cin >> x;
		x ^= ans;
		cout<<"in\n";
		p[x].push_back(i);
		p[i].push_back(x);
		st.clear();
		dfs1(1, 0);
		ans = 0;
		dfs2(i, x, 1);
	}
	return 0;
}
 
